/*
 * test/test.c
 *
 * Harry Wei <harryxiyou@gmail.com> (C) 2012
 *
 * Test case for lexical dynamic library
 */
#include <glib.h>
#include <stdlib.h>
#include "cp_ctrl.h"

int main(int argc, char **argv) {
	g_message("enter test main func ...");
	struct la *ctrl = NULL;
	int ret = 0;
	ctrl = g_malloc0(sizeof(struct la));
	if (NULL == ctrl) {
		g_message("%s -- Allocate error!", __func__);
		return -1;
	}
	//Lexical Analyser Test
	ret = la_init(ctrl);
	g_assert(ret==0);
	ret = get_source_file(ctrl, argv[1]);
	g_assert(ret == 0);
	fprintf(stdout, "file content[%s]\n", ctrl->buff);
	ret = preprocess(ctrl);
	g_message("%s -- ret is [%d]", __func__, ret);
	g_assert(ret==0);
	ret = scan_buff2words(ctrl);
	g_assert(ret == 0);
	ret = get_words2file(ctrl);
	g_assert(ret == 0);
	//Synatx Analyser Test
	ret = get_input_words(ctrl);
	g_assert(ret == 0);
	ret = get_ll_table(ctrl);
	g_assert(ret == 0);
	ret = init_stack(ctrl);
	g_assert(ret == 0);
	ret = syntax(ctrl);
	g_assert(ret == 0);
	g_free(ctrl); /* XXX free bug !?*/
	g_message("leave test main func ...");
	return 0;
}
